/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.db.cfg;

import java.sql.Timestamp;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 存放环境变量
 * 
 * 
 */
public final class Environment {
	private static final Log log = LogFactory.getLog(Environment.class);
	/**
	 * 指定数据库方言类
	 */
	public static final String DIALECT = "edidb.connection.dialect";
	/**
	 * 数据库连接提供类
	 */
	public static final String CONNECTION_PROVIDER = "edidb.connection.provider_class";
	 /**
	 * 数据库连接驱动类
	 */
	 public static final String DRIVER="edidb.connection.driver_class";
	/**
	 * 数据库方言忽略大小写
	 */
	public static final String DIALECT_IGNORECASE = "edidb.connection.dialect.ignoreCase";

	/**
	 * JDBC url
	 */
	 public static final String URL="edidb.connection.url";
	/**
	 * 数据库连接用户名
	 */
	public static final String USERNAME = "edidb.connection.username";
	/**
	 * 连接密码
	 */
	public static final String PASSWD = "edidb.connection.password";

	/**
	 * JNDI前缀
	 */
	public static final String JNDI_PREFIX = "edidb.jndi";

	public static final String JNDINAME = "edidb.connection.jndiname";
	/**
	 * connection前缀
	 */
	public static final String CONNECTION_PREFIX = "edidb.connection";

	/**
	 * 连接最大数
	 */
	public static final String MAXCONNECTIONS = "edidb.connection.minConnections";
	/**
	 * 连接最小数
	 */
	public static final String MINCONNECTIONS = "edidb.connection.maxConnections";

	/**
	 * 超时
	 */
	public static final String CONNECTIONTIMEOUT = "edidb.connection.connectionTimeout";

	private static final boolean JVM_HAS_JDK14_TIMESTAMP; // JVM1.4
	private static final boolean JVM_HAS_TIMESTAMP_BUG;

	// 数据库服务器地址
	public static final String SERVER = "edidb.connection.server";
	public static final String DBNAME = "edidb.connection.dbname";

	/**
	 * 
	 */
	static {
		Timestamp t = new Timestamp(0);
		t.setNanos(5 * 1000000);
		JVM_HAS_JDK14_TIMESTAMP = t.getTime() == 5;
		JVM_HAS_TIMESTAMP_BUG = new Timestamp(123456789).getTime() != 123456789;
	}

	public static boolean jvmHasJDK14Timestamp() {
		return JVM_HAS_JDK14_TIMESTAMP;
	}

	public static boolean jvmHasTimestampBug() {
		return JVM_HAS_TIMESTAMP_BUG;
	}

}
